package com.zoffy.oj_backend.judge;

import com.zoffy.oj_backend.judge.codesandbox.model.JudgeInfo;
import com.zoffy.oj_backend.judge.strategy.DefaultJudgeJudgeStrategy;
import com.zoffy.oj_backend.judge.strategy.JudgeContext;
import com.zoffy.oj_backend.judge.strategy.JudgeStrategy;
import org.springframework.stereotype.Component;

@Component
public class JudgeManager {
    private static final double  MULTIPLE_TIME_PYTHON=77.307692;
    public JudgeInfo doJudge(JudgeContext judgeContext){
        modifyJudgeInfo(judgeContext);
        JudgeStrategy judgeStrategy =new DefaultJudgeJudgeStrategy();
        return judgeStrategy.doJudge(judgeContext);
    }
    private void modifyJudgeInfo(JudgeContext judgeContext){
        String lang = judgeContext.getLang();
        JudgeInfo judgeInfo = judgeContext.getJudgeInfo();
        Long time = judgeInfo.getTime();
        switch (lang.toLowerCase()){
            case "java":
                break;
            case "python":
                judgeInfo.setTime((long)(time*MULTIPLE_TIME_PYTHON));
                break;
        }
    }
}
